package widgets;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.View.OnTouchListener;
import android.widget.RelativeLayout;

public class RelativeLayoutTest2 extends RelativeLayout implements OnClickListener, OnTouchListener, OnLongClickListener {
	//	private static final String TAG = RelativeLayoutTest2.class.getSimpleName();
	private static final String TAG = "L2222";
	/**
	 * 懒得删除了
	 */
	private String w = "";

	public RelativeLayoutTest2(Context context, AttributeSet attrs) {
		super(context, attrs);
		Log.v(TAG, "RelativeLayoutTest" + "\t" + w);
		//				this.setOnClickListener(this);
		//		this.setOnTouchListener(this);
		this.setOnLongClickListener(this);
	}

	@Override
	public boolean dispatchTouchEvent(MotionEvent ev) {
		Log.v(TAG, "dispatchTouchEvent" + "\t" + w);
		return super.dispatchTouchEvent(ev);
		//		return false;
		// 返回true的话则事件被消化，继续响应信息的touch事件（返回true）
		// 当手指按着不动的话则不断得循环处理touch事件（返回true）
		//		return true;
	}

	@Override
	public boolean onInterceptTouchEvent(MotionEvent ev) {
		Log.v(TAG, "onInterceptTouchEvent" + "\t" + w);

		return super.onInterceptTouchEvent(ev);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		Log.v(TAG, "onTouchEvent" + "\t" + w);

		switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:
			Log.v(TAG, "↓↓↓↓" + "\t" + w);
			break;
		case MotionEvent.ACTION_MOVE:
			Log.v(TAG, "→←→←→←" + "\t" + w);
			break;
		case MotionEvent.ACTION_UP:
			Log.v(TAG, "↑↑↑↑" + "\t" + w);
			break;
		case MotionEvent.ACTION_SCROLL:
			Log.v(TAG, "→←↑↓→←↑↓" + "\t" + w);
			break;
		default:
			break;
		}

		// 阻塞处理（循环处理）- -貌似是错误的结论
		//						return super.onTouchEvent(event);
		//		return false;
		return true;
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		Log.v(TAG, "onTouch" + "\t" + w);
		//		return true;
		return false;
	}

	@Override
	public void onClick(View v) {

		Log.v(TAG, "onClick" + "\t" + w);
	}

	@Override
	public boolean onLongClick(View v) {
		Log.v(TAG, "onLongClick" + "\t" + w);
		return false;
	}
}
